#include "widget.h"
#include "ui_widget.h"
#include<QTime>
#include<QDebug>

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
    hideui();

    InitConnect();
}
void Widget::hideui(){
    ui->menuWidget->hide();
    ui->deepseekWidget->hide();
    ui->audioWidget->hide();
    ui->arsWidget->hide();
    ui->v4l2Widget->hide();
    ui->Vodiowidget->hide();
    ui->photoWidget->hide();
    ui->control_Widget->hide();
    ui->TCPserverWidget->hide();
    ui->Weatherwidget->hide();
    ui->map_baiduwidget->hide();
    ui->APWidget->hide();
    ui->BlueToothWidget->hide();
}
void Widget::InitConnect(){
    connect(ui->menuWidget,&Menu::ShowDeepseek,this,&Widget::ShowDeepseek);//从菜单界面切换到ｄｅｅｐｓｅｅｋ界面
    connect(ui->menuWidget,&Menu::closeUI,this,&Widget::close);//退出程序
    connect(ui->deepseekWidget,&DeepSeek::showMenu,this,&Widget::showMenu);//从ｄｅｅｐｓｅｅｋ界面回到菜单界面
    connect(ui->LoginWidget,&Login::LoginSeccess,this,&Widget::showMenu);//从登录界面到菜单界面
    connect(ui->menuWidget,&Menu::showAudio,this,&Widget::showAudio);//显示音频播放界面
    connect(ui->audioWidget,&Audio::showMenu,this,&Widget::showMenu); //从音频播放界面到主界面
    connect(ui->menuWidget,&Menu::showArs,this,&Widget::showArs);//显示语音识别界面
    connect(ui->menuWidget,&Menu::showv4l2,this,&Widget::showv4l2);//显示ｖ４ｌ２界面
    connect(ui->menuWidget,&Menu::showVidio,this,&Widget::showvideo);//显示视频界面
    //connect(ui->photoWidget,&showphoto::showv4l2,this,&Widget::showv4l2);//显示ｖ４ｌ２界面
    connect(ui->v4l2Widget,&camera_Widget::showMenu,this,&Widget::showMenu);//从倒车影象到菜单界面
    connect(ui->arsWidget,&automatic::showMenu,this,&Widget::showMenu);//从语音识别界面到菜单界面
    connect(ui->Vodiowidget,&Vidioplayer::showMenu,this,&Widget::showMenu);//从视频播放界面到菜单界面
    connect(ui->menuWidget,&Menu::show_Control_light_alarm,this,&Widget::show_Control_light_alarm);
    //打开灯光报警
    connect(ui->menuWidget,&Menu::show_TCPserver_Widget,this,&Widget::show_TCPserver_Widget);//打开网络聊天
    connect(ui->menuWidget,&Menu::show_Weather_Widget,this,&Widget::show_Weather_Widget);//打开天气
    connect(ui->menuWidget,&Menu::show_map,this,&Widget::show_map);//打开天气
    connect(ui->map_baiduwidget,&map_baidu::show_Menu,this,&Widget::showMenu);//从地图到主桌面
    connect(ui->control_Widget,&Control_light_alarm::show_Menu,this,&Widget::showMenu);//从灯光和蜂鸣器到主桌面
    connect(ui->Weatherwidget,&Weather::show_Menu,this,&Widget::showMenu);//从天气到主桌面
    connect(ui->TCPserverWidget,&TCPserver::show_Menu,this,&Widget::showMenu);//从聊天到主桌面
    connect(ui->menuWidget,&Menu::show_Logout,this,&Widget::showLogout);//注销回到登录界面
    connect(ui->menuWidget,&Menu::show_BlueTooth,this,&Widget::showBlueTooth);//打开蓝牙界面
    connect(ui->BlueToothWidget,&BlueTooth::sendshowMenu,this,&Widget::showMenu);//从蓝牙回到主界面
    connect(ui->menuWidget,&Menu::show_AP3216C,this,&Widget::showAP3216C);//从主界面到ＡＰ３２１６Ｃ
    connect(ui->APWidget,&AP3216CWidget::showMenu,this,&Widget::showMenu);//返回菜单界面
}
Widget::~Widget()
{
    delete ui;
}

void Widget::ShowDeepseek()
{

    ui->menuWidget->close();
    ui->deepseekWidget->show();
}

void Widget::showMenu()
{
    ui->menuWidget->show();
    ui->LoginWidget->close();
    ui->deepseekWidget->close();
    ui->audioWidget->close();
    ui->v4l2Widget->close();
    ui->arsWidget->close();
    ui->Vodiowidget->close();
    ui->map_baiduwidget->close();
    ui->control_Widget->close();
    ui->Weatherwidget->close();
    ui->TCPserverWidget->close();
    ui->BlueToothWidget->close();
    ui->APWidget->close();
}

void Widget::showAudio()
{
    ui->menuWidget->close();
    ui->LoginWidget->close();
    ui->deepseekWidget->close();
    ui->audioWidget->show();
}

void Widget::showArs()
{
    ui->menuWidget->close();
    ui->LoginWidget->close();
    ui->deepseekWidget->close();
    ui->audioWidget->close();
    ui->arsWidget->show();
}

void Widget::showLogout()
{
    ui->menuWidget->close();
    ui->LoginWidget->show();
    ui->deepseekWidget->close();
    ui->audioWidget->close();
    ui->arsWidget->close();
    ui->photoWidget->close();
    ui->Vodiowidget->close();
    ui->control_Widget->close();
    ui->TCPserverWidget->close();
    ui->Weatherwidget->close();
    ui->map_baiduwidget->close();
}

void Widget::showAP3216C()
{
    ui->menuWidget->close();
    ui->LoginWidget->close();
    ui->deepseekWidget->close();
    ui->audioWidget->close();
    ui->arsWidget->close();
    ui->photoWidget->close();
    ui->Vodiowidget->close();
    ui->control_Widget->close();
    ui->TCPserverWidget->close();
    ui->Weatherwidget->close();
    ui->map_baiduwidget->close();
    ui->APWidget->show();
}

void Widget::showv4l2()
{
    ui->menuWidget->close();
    ui->LoginWidget->close();
    ui->deepseekWidget->close();
    ui->audioWidget->close();
    ui->arsWidget->close();
    ui->photoWidget->close();
    ui->v4l2Widget->show();

}

void Widget::showphoto()
{
    ui->menuWidget->close();
    ui->LoginWidget->close();
    ui->deepseekWidget->close();
    ui->audioWidget->close();
    ui->arsWidget->close();


    ui->photoWidget->show();
}

void Widget::showvideo()
{
    ui->menuWidget->close();
    ui->LoginWidget->close();
    ui->deepseekWidget->close();
    ui->audioWidget->close();
    ui->arsWidget->close();
    ui->photoWidget->close();
    ui->Vodiowidget->show();
}

void Widget::show_Control_light_alarm()
{
    ui->menuWidget->close();
    ui->LoginWidget->close();
    ui->deepseekWidget->close();
    ui->audioWidget->close();
    ui->arsWidget->close();
    ui->photoWidget->close();
    ui->Vodiowidget->close();
    ui->control_Widget->show();
}

void Widget::show_TCPserver_Widget()
{
    ui->menuWidget->close();
    ui->LoginWidget->close();
    ui->deepseekWidget->close();
    ui->audioWidget->close();
    ui->arsWidget->close();
    ui->photoWidget->close();
    ui->Vodiowidget->close();
    ui->control_Widget->close();
    ui->TCPserverWidget->show();
}

void Widget::show_Weather_Widget()
{
    ui->menuWidget->close();
    ui->LoginWidget->close();
    ui->deepseekWidget->close();
    ui->audioWidget->close();
    ui->arsWidget->close();
    ui->photoWidget->close();
    ui->Vodiowidget->close();
    ui->control_Widget->close();
    ui->TCPserverWidget->close();
    ui->Weatherwidget->show();
}

void Widget::show_map()
{
    ui->menuWidget->close();
    ui->LoginWidget->close();
    ui->deepseekWidget->close();
    ui->audioWidget->close();
    ui->arsWidget->close();
    ui->photoWidget->close();
    ui->Vodiowidget->close();
    ui->control_Widget->close();
    ui->TCPserverWidget->close();
    ui->Weatherwidget->close();
    ui->map_baiduwidget->show();
}

void Widget::showBlueTooth()
{
    ui->menuWidget->close();
    ui->LoginWidget->close();
    ui->deepseekWidget->close();
    ui->audioWidget->close();
    ui->arsWidget->close();
    ui->photoWidget->close();
    ui->Vodiowidget->close();
    ui->control_Widget->close();
    ui->TCPserverWidget->close();
    ui->Weatherwidget->close();
    ui->map_baiduwidget->close();
    ui->BlueToothWidget->show();
}

